<template>
  <div class="page">
    <!-- 搜索区域 开始 -->
    <div class="el_card_box">
      <el-form
        :inline="true"
        size="small"
        :model="formInline"
        class="search_form"
      >
        <el-form-item label="最后访问时间：">
          <el-date-picker v-model="formInline.orderTime" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="关键词：">
          <el-input v-model="formInline.key" placeholder="授权号码"></el-input>
        </el-form-item>
      </el-form>
      <div class="search_btn_box">
        <el-button type="primary" size="small" @click="getList">筛选</el-button>
        <el-button type="default" size="small" @click="rest"
          >清空筛选</el-button
        >
      </div>
    </div>
    <!-- 搜索区域 end -->

    <!-- 表格 开始 -->
    <div class="table_box">
      <el-table ref="elTable" class="el_table" size="small" :data="tableData">
        <el-table-column prop="phoneNumber" label="手机号码" />
        <el-table-column
          prop="cityName"
          label="查询城市"
          show-overflow-tooltip
        />
        <el-table-column
          prop="dentalCondition"
          label="牙齿情况"
          show-overflow-tooltip
        />
        <el-table-column
          prop="queryTime"
          label="查询时间"
          show-overflow-tooltip
        />
        <el-table-column
          prop="lastAccessIp"
          label="最后访问ip"
          show-overflow-tooltip
        />
        <el-table-column prop="status" label="状态" show-overflow-tooltip>
          <template slot-scope="{ row }">{{
            row.status == 1 ? "已标记" : "未标记"
          }}</template>
        </el-table-column>
        <el-table-column
          prop="address"
          label="操作"
          width="200px"
          align="center"
        >
          <template slot-scope="{ row }">
            <el-link
              type="primary"
              class="el_link"
              :underline="false"
              v-if="row.status != 1"
              :id="row.id"
              @click="signEvent(row)"
              >标记</el-link
            >
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination_list">
        <el-pagination
          background
          layout="sizes, total,prev, pager, next, jumper"
          :total="pageTotal"
          :page-size="pageSize"
          :page-sizes="pageSizes"
          :current-page.sync="pageNumber"
          @current-change="getList"
          @size-change="changePageSize"
        />
      </div>
    </div>
    <!-- 表格 end -->
  </div>
</template>
    
<script>
import { showToast, showModal, deepClone } from "@/common/util";
import { GET_QUERY_PRICE_LIST, MARK_QUERY_PRICE_INFO } from "@/http/interface";
export default {
  data() {
    return {
      formInline: {},
      tableData: [],
      pageTotal: 0,
      pageNumber: 1,
      pageSizes: [10, 20, 50, 100],
      pageSize: 20,
      loading: false,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    /** 重置 */
    rest() {
      this.formInline = {};
      this.orderTime = [];
      this.getList();
    },

    /** 每页展示 */
    changePageSize(e) {
      this.pageSize = e;
      this.getList();
    },

    /** 获取参数 */
    getParams() {
      let oParams = JSON.parse(JSON.stringify(this.formInline));
      let n = oParams.orderTime;

      if (n && n.length > 0) {
        oParams.start = n[0];
        oParams.end = n[1];
      }

      delete oParams.orderTime;

      oParams.current = this.pageNumber;
      oParams.size = this.pageSize;
      return oParams;
    },

    /** 获取列表 */
    getList() {
      let _this = this;
      let oParams = this.getParams();
      GET_QUERY_PRICE_LIST(oParams).then((res) => {
        let obj = res.data || {};
        _this.tableData = obj.records || [];
        _this.pageTotal = obj.total;
      });
    },

    // 标记
    signEvent(row) {
      let _this = this;
      showModal({
        message: `确认将该条数据标记吗？`,
        showCancelButton: true,
        type:'warning',
        success: function () {
          let oParams = {};
          oParams.id = row.id;
          MARK_QUERY_PRICE_INFO(oParams).then((res) => {
            if (res.code == 200) {
              showToast({
                message: "标记成功",
                type: "success",
              });
              _this.getList();
            }
          });
        },
      });
    },
  },
};
</script>
    
    <style lang="scss" scoped>
@import "@/assets/style/customer/index.scss";
</style>
    